#include "appealwindow.h"
#include "ui_appealwindow.h"
#include<QMouseEvent>
appealwindow::appealwindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::appealwindow)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint); // 设置窗口无边框
    ui->label->setWordWrap(true); // 开启自动换行
    ui->label->setAlignment(Qt::AlignLeft | Qt::AlignTop);
}

appealwindow::~appealwindow()
{
    delete ui;
}

void appealwindow::on_pushButton_2_clicked()
{
    this->close();
}

void appealwindow::setText(QString text){
    ui->label->setText(text);
}

void appealwindow::mousePressEvent(QMouseEvent *event) {
    if (event->button() == Qt::LeftButton) {
                initialMousePosition = event->globalPos(); // 记录鼠标按下时的全局位置
                isDragging = true; // 开始拖动
            }
    }

void appealwindow::mouseMoveEvent(QMouseEvent *event){
    if (isDragging && event->buttons() & Qt::LeftButton) {
                QPoint delta = event->globalPos() - initialMousePosition; // 计算鼠标移动的距离
                move(x() + delta.x(), y() + delta.y()); // 根据鼠标移动的距离来移动窗口
                initialMousePosition = event->globalPos(); // 更新鼠标位置
            }
    }
void appealwindow::mouseReleaseEvent(QMouseEvent *event) {
        if (event->button() == Qt::LeftButton) {
            isDragging = false; // 结束拖动
        }
    }
